<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div class="common">
    <h1>添加假条</h1>
    <form action="" method="post" onsubmit="return chkForm()">
        <table cellpadding="0" cellspacing="0" border="1">
            <tr>
                <td>学生姓名</td>
                <td><input type="text" name="stu_name" placeholder="学生姓名" class="stu_name"></td>
            </tr>
            <tr>
                <td>请假事由</td>
                <td><input type="text" name="content" placeholder="请假事由" class="content"></td>
            </tr>
            <tr>
                <td>请假时间</td>
                <td><input type="date" name="time" class="time"></td>
            </tr>
            <tr>
                <td>请假类型</td>
                <td>
                    <select name="tid_id" id="">
                    {% for i in type %}
                        <option value="{{ i.id }}">{{ i.tname }}</option>
                    {% endfor %}
                    </select>
                </td>
            </tr>
            <tr>
                <td colspan="2"><input type="submit" value="添加"></td>
            </tr>
        </table>

    </form>
</div>
<script>
     function $$(selector){
            return document.querySelector(selector)
        }
     function chkForm(){
         var stu_name = $$('.stu_name').value
         var content = $$('.content').value
         var time = $$('.time').value
         if(stu_name == '' || content == '' || time == ''){
             alert('请完善信息')
             return false
         }
     }
</script>
</body>
</html>